//
//  UILabel+Category.m
//  KeleAppProject
//
//  Created by Cen Zhou on 2018/1/10.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "UILabel+Category.h"

@implementation UILabel (Category)

- (void)setRowSpace:(CGFloat)rowSpace
{
    self.numberOfLines = 0;
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithAttributedString:self.attributedText];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:rowSpace];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [self.text length])];
    self.attributedText = attributedString;
}

- (void) changeTextColorWithRange:(NSRange)range color:(UIColor *)color{
    NSMutableAttributedString *mutAttStr = [[NSMutableAttributedString alloc]initWithString:self.text];
    [mutAttStr addAttribute:NSForegroundColorAttributeName value:color range:range]; //设置颜色
    self.attributedText = mutAttStr;
}


// 设置圆角
- (void)setRadiusWithValue:(NSInteger)value{
    UIBezierPath* path = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:value];
    CAShapeLayer* shape = [CAShapeLayer new];
    shape.path = path.CGPath;
    self.layer.mask = shape;
}

@end
